﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace collection_arraylist_practice
{
    class Program
    {
        static void Main(string[] args)
        {
            ArrayList course = new ArrayList() { "语文", "数学", "英语" };
            course.Add("面向对象编程");
            Console.WriteLine("您已报的课程有：");
            foreach (string item in course)
            {
                Console.Write(item+",");
            }
            Console.WriteLine();
            Console.WriteLine("还需要报什么课程：");
            while (true)
            {
                course.Add(Console.ReadLine());

                Console.WriteLine("是否继续添加(y/n)");
                string a = Console.ReadLine();

                if(a == "y") {
                    Console.WriteLine("请输入课程：");
                    course.Add(Console.ReadLine());
                }
                else if(a=="n")
                {
                    break;

                } 
             }
                Console.WriteLine("现有课程为：");
                foreach (string item in course)
                {
                    Console.Write(item + ",");
                }
                Console.WriteLine();
            


        }
    }
}
